Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOM test class changes #8

Merged
merged 4 commits into from
Nov 22, 2024
Merged

DOM test class changes #8

merged 4 commits into from
Nov 22, 2024

Conversation

dphiffer
Copy link
Contributor

@dphiffer dphiffer commented Nov 22, 2024

Adds a "change classes" aspect to DOM tests: add a class or remove a class.

Example: "turn the nav donate button pink"
Screenshot 2024-11-22 at 12 01 43 PM

@dphiffer dphiffer requested a review from BatMiles November 22, 2024 17:02
let targets = document.querySelectorAll(change.selector);
for (let target of targets) {
if (change.change == 'add') {
target.classList.add(change.class);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm missing something - wouldn't this code mean that the added/removed classes were always added/removed?

Copy link
Contributor Author

@dphiffer dphiffer Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it'll happen every time a variant lands on the page with a class add/removal, but that will only happen some of the time. fwiw DomTests.php:76 is where that random selection happens.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it, thanks!

Copy link
Member

@BatMiles BatMiles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, looks good! Left one code question

@dphiffer dphiffer merged commit b83e66e into main Nov 22, 2024
@dphiffer dphiffer deleted the dom-classes branch November 22, 2024 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants